The Noise Floor: An Anatomy of Random Matrices

噪声地板:随机矩阵解剖

为什么纯噪声矩阵的特征值不会都相等?从 Marchenko–Pastur 律与 BBP 相变出发,用模拟和三套真实数据(airway、PBMC 3k、CPTAC)说明 PCA 里哪些成分是真的、该保留几个、以及样本量如何决定你能看见什么。
Tooling
Author

Jie Hua

Published

Nov 25, 2026

写作说明 / Note

本文由 AI(Trae Agent) 检索、整理并撰写,尚未经过人工逐条校对。所有数字都来自随文附带的 R 脚本(scripts/00_data.R 至 03_practice.R)的真实运行结果,图也由这些脚本生成;outputs/metrics.json 里存着正文引用的每一个值。Marchenko–Pastur 律、BBP 相变、Gavish–Donoho 阈值与 Ledoit–Wolf 收缩都是已发表的结论,公式按原文给出,实现是我自己写的,并与模拟结果做了对照;凡是理论值与模拟值有出入的地方都在正文注明了。

This article was researched and written by an AI system (Trae Agent) and has not been proofread line by line by a human. Every number comes from an actual run of the R scripts shipped with the post (scripts/00_data.R to 03_practice.R), and every figure is produced by those scripts; outputs/metrics.json holds each value quoted below. The Marchenko–Pastur law, the BBP transition, the Gavish–Donoho threshold and Ledoit–Wolf shrinkage are published results; the formulas follow the original papers, the implementations are mine, and they are checked against simulation. Any gap between theory and simulation is stated in the text.

写一篇中英双语长文,讲清随机矩阵理论在生物数据分析里的实际含义:从样本协方差为什么有谱、Marchenko–Pastur 律、边缘涨落、BBP 相变讲起,再用模拟(纯噪声、单个 spike、相位扫描)和三套真实数据(bulk RNA-seq 的 airway、单细胞 PBMC 3k、蛋白组 CPTAC)验证;最后给出「该保留几个主成分」的三条规则对比、硬阈值降噪、收缩估计与样本量对噪声地板的影响。要求所有数字由随附 R 脚本生成并在正文用 inline R 引用,公式给出出处,理论与模拟的偏差如实报告。

A long bilingual post on what random-matrix theory actually means for biological data: why the sample covariance has a limiting spectrum, the Marchenko–Pastur law, edge fluctuations, the BBP transition, then simulations (pure noise, one spike, a phase scan) and three real datasets (bulk RNA-seq airway, single-cell PBMC 3k, proteomics CPTAC); finally three rules for choosing the number of components, hard-threshold denoising, shrinkage, and how sample size sets the noise floor. Every number must be generated by the shipped R scripts and quoted with inline R; formulas must cite their source, and deviations between theory and simulation must be reported honestly.

1. 一个数字 / A number

先给一个数字。在 airway 这个只有 8 个样本的 RNA-seq 数据集里,如果我把每个基因标准化,然后对 24,706 个基因做一次主成分分析,即使数据全是噪声,第一主成分也会解释 13.0% 的方差。

Here is a number. In the airway RNA-seq dataset, which has only 8 samples, standardise every gene and run a PCA over 24,706 genes: even if the data were pure noise, the first principal component would explain 13.0% of the variance.

这不是一个比喻,也不是某个实现的 bug,而是一个可以精确写下来的极限:当特征数 \(p\) 远大于样本数 \(n\) 时,任何 \(p \times n\) 的随机矩阵,其样本协方差的最大特征值都会收敛到 \(\sigma^2(1+\sqrt{p/n})^2\)。把这个数除以特征总数 \(p\),得到的就是上面那个比例。它是噪声地板:在你解释任何一个主成分之前,先要知道纯噪声能把它推到多高。

This is not a metaphor and not a bug in some implementation; it is an exact limit. When the number of features \(p\) is much larger than the sample size \(n\), the largest eigenvalue of the sample covariance of any \(p \times n\) random matrix converges to \(\sigma^2(1+\sqrt{p/n})^2\). Divide that by the number of features \(p\) and you get the number above. This is the noise floor: before interpreting any component, you need to know how high pure noise can push it.

本文要做的,就是把这一句话拆开:它从哪来,什么时候成立,在真实数据里长什么样,以及它如何改变「该保留几个主成分」这个日常决定。

This post unpacks that one sentence: where it comes from, when it holds, what it looks like on real data, and how it changes the everyday decision of how many components to keep.

2. 数据的形状 / The shape of the data

所有讨论都从一张矩阵开始。行是特征(基因、蛋白、代谢物),列是样本(病人、细胞、运行),\(X\) 是 \(p \times n\)。生物的组学数据几乎总是 \(p \gg n\):转录组两万个基因配十个样本,蛋白组一千个蛋白配六次运行,单细胞两万个基因配几千个细胞。

Everything starts from one matrix. Rows are features (genes, proteins, metabolites), columns are samples (patients, cells, runs), and \(X\) is \(p \times n\). Biological omics data are almost always \(p \gg n\): twenty thousand genes against ten samples, a thousand proteins against six runs, twenty thousand genes against a few thousand cells.

\(p/n\) 这个比值后面会反复出现,给它一个名字:\(\gamma = p/n\)。它是这篇文章里唯一真正重要的参数。\(\gamma\) 越大,噪声地板越高;\(\gamma\) 越小,你能看见的结构越多。

That ratio will keep coming back, so name it: \(\gamma = p/n\). It is the only parameter that really matters here. The larger \(\gamma\), the higher the floor; the smaller \(\gamma\), the more structure you can see.

三套真实数据的形状如下(数字由 scripts/00_data.R 生成):

The three real datasets have the shapes below (numbers from scripts/00_data.R):

数据 / Dataset 特征 p / Features 样本 n / Samples γ 类型 / Type
airway 24,706 8 3088 bulk RNA-seq(log2 CPM)
PBMC 3k 2,000 1,200 1.67 single cell(log1p CPM)
CPTAC 1,101 6 183.5 LFQ 蛋白组(log2 intensity)

注意 PBMC 那一行:为了算得动,单细胞部分随机取了 2,000 个高变基因和 1,200 个细胞;真正用到全部 11,139 个基因和 2,700 个细胞时 \(\gamma\) 会更大。这一点在正文里会再说明一次。

Note the PBMC row: to keep the computation cheap, the single-cell section uses 2,000 highly variable genes and 1,200 randomly chosen cells; with all 11,139 genes and 2,700 cells \(\gamma\) would be larger. This is repeated where it matters.

3. 样本协方差与它的谱 / The sample covariance and its spectrum

先把每个特征标准化(减均值、除标准差),这样每个特征的方差都是 1,\(\sigma^2 = 1\),噪声地板只由 \(\gamma\) 决定。然后算样本协方差

Standardise every feature first (subtract the mean, divide by the standard deviation), so that every feature has variance 1, \(\sigma^2 = 1\), and the floor depends on \(\gamma\) alone. Then form the sample covariance

\[ S = \frac{1}{n} X X^\top \in \mathbb{R}^{p \times p}. \]

\(S\) 是 \(p \times p\) 的,直接求特征值在 \(p = 24{,}706\) 时不现实,但当 \(p > n\) 时它最多只有 \(n-1\) 个非零特征值(行被中心化后每一行加起来是 0),而这些非零特征值与 \(n \times n\) 的 Gram 矩阵 \(G = \frac{1}{n} X^\top X\) 的 \(n\) 个特征值完全相同。所以代码里永远算小的一边:

\(S\) is \(p \times p\), which is impractical at \(p = 24{,}706\). But when \(p > n\) it has at most \(n-1\) non-zero eigenvalues (each row sums to zero after centring), and those non-zero eigenvalues coincide with the \(n\) eigenvalues of the \(n \times n\) Gram matrix \(G = \frac{1}{n} X^\top X\). So the code always diagonalises the smaller side:

spectrum <- function(X, standardize = TRUE) {
  if (standardize) X <- standardize_rows(X)
  p <- nrow(X); n <- ncol(X)
  if (p <= n) {
    ev <- eigen(tcrossprod(X) / n, symmetric = TRUE, only.values = TRUE)$values
  } else {
    ev <- eigen(crossprod(X) / n, symmetric = TRUE, only.values = TRUE)$values
  }
  sort(pmax(ev, 0), decreasing = TRUE)
}

顺带一个常被忽略的推论:\(n\) 个样本最多给出 \(n-1\) 个有意义的成分(第 \(n\) 个恰好是 0)。在 airway 里就是 7 个,不是 8 个。

One corollary is easy to miss: \(n\) samples give at most \(n-1\) meaningful components (the \(n\)-th is exactly zero). For airway that is 7, not 8.

整个分析链条只有四步,后面所有实验都在这条链上做文章:

The whole analysis is a four-step chain, and every experiment below works on this chain:

flowchart TD
  A["p × n 数据矩阵 / data matrix"] --> B["按特征标准化 / standardise rows"]
  B --> C["S = X Xᵀ / n"]
  C --> D["特征值 λ₁ ≥ λ₂ ≥ …"]
  D --> E{"与噪声地板比较 / vs the floor"}
  E --> F["λ ≫ λ₊:信号 / signal"]
  E --> G["λ ≈ λ₊:临界 / borderline"]
  E --> H["λ 落在 bulk:噪声 / noise"]

4. 为什么随机矩阵也有形状 / Why random matrices have a shape

直觉上,一个纯噪声矩阵应该什么结构都没有,特征值应该都挤在 1 附近。这是一个把「\(p\) 固定、\(n \to \infty\)」的直觉错误地套到了「\(p\) 和 \(n\) 一起长」的情形上。

Intuition says a pure noise matrix has no structure, so its eigenvalues should huddle around 1. That intuition wrongly transplants “\(p\) fixed, \(n \to \infty\)” into a regime where \(p\) and \(n\) grow together.

当 \(p\) 和 \(n\) 同阶增长时,特征值会散开成一段连续分布,宽度由 \(\gamma\) 决定。原因可以从自由概率的角度讲,也可以从「随机矩阵的 Stieltjes 变换满足一个不动点方程」讲;这里只保留最重要的结论:散开的宽度不是误差,而是这个极限本身的形状。样本协方差不是真实协方差的近似,它是一个有自己规律的另一个对象。

When \(p\) and \(n\) grow together, the eigenvalues spread into a continuous distribution whose width is set by \(\gamma\). The reason can be told through free probability, or through the fixed-point equation satisfied by the Stieltjes transform of a random matrix; here we keep only the essential point: the spread is not an error, it is the shape of the limit itself. The sample covariance is not an approximation of the true covariance; it is another object with its own laws.

接下来的每一张图,都是这句话的一个特例。

Every figure below is a special case of that sentence.

5. Marchenko–Pastur 律 / The Marchenko–Pastur law

\(\sigma^2 = 1\) 时,\(S\) 的经验谱分布收敛到

With \(\sigma^2 = 1\), the empirical spectral distribution of \(S\) converges to

\[ f(\lambda) = \frac{1}{2\pi \gamma \lambda}\sqrt{(\lambda_+ - \lambda)(\lambda - \lambda_-)}, \qquad \lambda \in [\lambda_-, \lambda_+], \]

其中

where

\[ \lambda_\pm = (1 \pm \sqrt{\gamma})^2 . \]

当 \(\gamma > 1\) 时,还有 \(1 - 1/\gamma\) 的质量堆在 \(\lambda = 0\) 上(这正是「最多 \(n\) 个非零特征值」的另一种说法);当 \(\gamma = 1\) 时 \(\lambda_- = 0\),密度在 0 处发散。

When \(\gamma > 1\) there is an extra atom of mass \(1 - 1/\gamma\) at \(\lambda = 0\) (which is the same statement as “at most \(n\) non-zero eigenvalues”); when \(\gamma = 1\), \(\lambda_- = 0\) and the density diverges at zero.

下图是三个纯噪声矩阵的实测谱,红线是上面的公式,虚线是 \(\lambda_\pm\)。三个面板分别对应 \(\gamma = 0.25\)、\(2\)、\(6\);最左与最右两个面板的实测 \(\lambda_{\max}\) 分别是 2.25 和 11.74,与理论边界 2.25、11.90 吻合。

Below are measured spectra of three pure-noise matrices: the red line is the formula, the dashed lines are \(\lambda_\pm\). The panels correspond to \(\gamma = 0.25\), \(2\) and \(6\); the observed \(\lambda_{\max}\) in the outermost panels are 2.25 and 11.74, against theoretical edges 2.25 and 11.90.

纯噪声矩阵的特征值谱与 Marchenko–Pastur 密度。直方图是一个模拟矩阵的实测谱,红线是公式,虚线是 \lambda_\pm。 | Spectrum of pure-noise matrices against the Marchenko–Pastur density. The histogram is one simulated matrix, the red line is the formula, the dashed lines are \lambda_\pm.

纯噪声矩阵的特征值谱与 Marchenko–Pastur 密度。直方图是一个模拟矩阵的实测谱,红线是公式,虚线是 \(\lambda_\pm\)。 | Spectrum of pure-noise matrices against the Marchenko–Pastur density. The histogram is one simulated matrix, the red line is the formula, the dashed lines are \(\lambda_\pm\).

把 \(\gamma\) 连续扫一遍,会看到整套曲线的族:\(\gamma\) 小的时候谱窄而靠左,\(\gamma\) 大的时候谱宽、右边界被推到很远的地方。\(\gamma = 1\) 那条(密度在 0 处发散)没有画进来,因为它被截断后会变成一条难看的平台。

Sweeping \(\gamma\) shows the whole family: small \(\gamma\) gives a narrow spectrum hugging small values, large \(\gamma\) gives a wide spectrum with the right edge pushed far out. The \(\gamma = 1\) curve is not drawn, because clipping its divergence at zero produces an unhelpful plateau.

不同 \gamma 下的 Marchenko–Pastur 密度(对数横轴,密度截断于 1.5)。 | Marchenko–Pastur densities for a range of \gamma (log axis, density clipped at 1.5).

不同 \(\gamma\) 下的 Marchenko–Pastur 密度(对数横轴,密度截断于 1.5)。 | Marchenko–Pastur densities for a range of \(\gamma\) (log axis, density clipped at 1.5).

6. 三个数字 / Three numbers

到这一步,所有判断都只需要三个量:

At this point every decision needs only three quantities:

\[ \gamma = \frac{p}{n}, \qquad \lambda_+ = (1+\sqrt{\gamma})^2, \qquad \text{floor} = \frac{\lambda_+}{p}. \]

第一个是形状参数,第二个是噪声能到达的上界,第三个才是可以拿去和「第一主成分解释了多少方差」直接比较的数字。把 \(\lambda_+\) 除以 \(p\) 之所以合理,是因为标准化之后所有特征值加起来恰好等于 \(p\)。

The first is the shape parameter, the second is the ceiling noise can reach, and the third is the number you can compare directly with “the share of variance in PC1”. Dividing \(\lambda_+\) by \(p\) makes sense because, after standardisation, the eigenvalues sum to exactly \(p\).

这张表把三套真实数据的三个数字列出来,最后两列是它们的实际表现:

This table lists the three numbers for the three real datasets, plus two columns on how they actually behave:

数据 / Dataset γ λ₊ 地板 / Floor 实测 PC1 / Observed PC1 比值 / Ratio
airway 3088 3200 13.0% 26.9% 2.07
PBMC 3k 1.67 5.25 0.26% 4.4% 16.6
CPTAC 183.5 211.6 19.2% 32.4% 1.69

7. 边缘不是一条硬线 / The edge is not a hard line

\(\lambda_+\) 是 \(n, p \to \infty\) 时的极限点,不是有限样本下的天花板。有限样本里,最大的特征值会在 \(\lambda_+\) 附近涨落,而且涨落幅度随 \(n\) 缩小得很慢:

\(\lambda_+\) is a limit point as \(n, p \to \infty\), not a ceiling at finite size. At finite size the largest eigenvalue fluctuates around \(\lambda_+\), and the fluctuation shrinks slowly with \(n\):

\[ \lambda_{\max} - \lambda_+ \;\asymp\; n^{-2/3}. \]

这个 \(-2/3\) 指数是 Tracy–Widom 分布的尺度,它也是「随机矩阵的边缘涨落不是高斯的」最直接的证据。下图用方阵模拟估了这个指数:从 \(n = 50\) 到 \(800\),\(\lambda_{\max}\) 的标准差确实按约 -0.65 的幂次下降,与 \(-2/3\) 接近。

That \(-2/3\) exponent is the Tracy–Widom scale, and it is the most direct evidence that edge fluctuations of random matrices are not Gaussian. The figure below estimates it from square simulations: from \(n = 50\) to \(800\), the standard deviation of \(\lambda_{\max}\) falls with an exponent of about -0.65, close to \(-2/3\).

最大特征值的标准差随矩阵维度下降,双对数坐标下的斜率接近 -2/3。 | Standard deviation of the largest eigenvalue against matrix size; the log-log slope is close to -2/3.

最大特征值的标准差随矩阵维度下降,双对数坐标下的斜率接近 \(-2/3\)。 | Standard deviation of the largest eigenvalue against matrix size; the log-log slope is close to \(-2/3\).

实践含义:如果在纯噪声上算 \(\lambda_{\max}\),它大约有一半的机会超过 \(\lambda_+\)。所以「超过 \(\lambda_+\) 就算信号」这条规则,在没有任何校正时,假阳性率接近 50%。后面的平行分析就是在修这个问题。

Practical consequence: on pure noise, \(\lambda_{\max}\) has roughly a 50% chance of exceeding \(\lambda_+\). So the rule “anything above \(\lambda_+\) is signal” has a false-positive rate near 50% without correction. The parallel analysis later in the post is the fix.

8. 加一个信号 / Adding one signal

现在往噪声里放一个真实的信号。取一个单位向量 \(u\),令总体协方差为

Now put one real signal into the noise. Take a unit vector \(u\) and set the population covariance to

\[ \Sigma = I + \ell\, u u^\top , \]

也就是在单位协方差上叠一个特征值 \(1 + \ell\) 的方向。\(\ell\) 是信号强度:\(\ell\) 越大,这个方向越突出。

that is, a direction with eigenvalue \(1+\ell\) on top of the identity. \(\ell\) is the signal strength: the larger \(\ell\), the more prominent the direction.

样本里看到的第一特征值并不仅仅等于 \(1+\ell\),它还取决于 \(\gamma\),因为噪声会把这个方向「压回来」。这正好是下一个话题。

The leading eigenvalue you see in a sample is not simply \(1+\ell\); it also depends on \(\gamma\), because noise pushes the direction back. That is exactly the next topic.

9. BBP 相变 / The BBP transition

Baik–Ben Arous–Péché 定理给出了一个尖锐的答案。当

The Baik–Ben Arous–Péché theorem gives a sharp answer. When

\[ \ell \le \sqrt{\gamma}, \]

信号完全看不见:第一特征值仍然收敛到 \(\lambda_+ = (1+\sqrt{\gamma})^2\),第一特征向量与 \(u\) 的夹角趋近 90°。当 \(\ell > \sqrt{\gamma}\) 时,

the signal is invisible: the leading eigenvalue still converges to \(\lambda_+ = (1+\sqrt{\gamma})^2\) and the leading eigenvector becomes asymptotically orthogonal to \(u\). When \(\ell > \sqrt{\gamma}\),

\[ \lambda_1 \to (1+\ell)\left(1 + \frac{\gamma}{\ell}\right), \qquad \cos^2 \angle(\hat v_1, u) \to \frac{1 - \gamma/\ell^2}{1 + \gamma/\ell}. \]

注意这个结果的两个反直觉之处。第一,阈值是 \(\sqrt{\gamma}\) 而不是 1,所以样本数越少(\(\gamma\) 越大),越强的信号才能被看见。第二,即便过了阈值,特征向量的对齐程度也不是 1:\(\ell = 5, \gamma = 4\) 时 \(\cos^2\) 只有 0.43。

Note two counter-intuitive consequences. First, the threshold is \(\sqrt{\gamma}\), not 1, so the fewer samples you have (the larger \(\gamma\)), the stronger the signal must be to be seen. Second, even above the threshold the eigenvector is not perfectly aligned: at \(\ell = 5\) and \(\gamma = 4\), \(\cos^2\) is only 0.43.

模拟里 \(\gamma = 4\)(阈值 \(\ell = 2\)):\(\ell = 1\) 时第一特征值是 8.90,理论值 9.00,还贴着 \(\lambda_+\);\(\ell = 5\) 时是 10.58,理论值 10.80,明显脱离。

In the simulation with \(\gamma = 4\) (threshold \(\ell = 2\)): at \(\ell = 1\) the leading eigenvalue is 8.90 against a theoretical 9.00, still pinned to \(\lambda_+\); at \(\ell = 5\) it is 10.58 against 10.80, clearly detached.

第一特征值随信号强度的变化。灰虚线是 \lambda_+,灰点线是阈值 \ell = \sqrt{\gamma}。 | Leading eigenvalue against signal strength. The dashed line is \lambda_+, the dotted line is the threshold \ell = \sqrt{\gamma}.

第一特征值随信号强度的变化。灰虚线是 \(\lambda_+\),灰点线是阈值 \(\ell = \sqrt{\gamma}\)。 | Leading eigenvalue against signal strength. The dashed line is \(\lambda_+\), the dotted line is the threshold \(\ell = \sqrt{\gamma}\).

第一特征向量与真实信号的平方余弦。阈值以下恒为 0(有限样本里只有很小的残余),阈值以上才单调上升。 | Squared cosine between PC1 and the true signal. It is zero below the threshold (up to a small finite-sample residue) and rises only above it.

第一特征向量与真实信号的平方余弦。阈值以下恒为 0(有限样本里只有很小的残余),阈值以上才单调上升。 | Squared cosine between PC1 and the true signal. It is zero below the threshold (up to a small finite-sample residue) and rises only above it.

10. 检测极限随样本量移动 / The detection limit moves with n

把 \(\ell\) 换成横轴、把第一特征值除以 \(\lambda_+\),就能把五条不同 \(\gamma\) 的曲线放进同一张图。每条曲线都在自己的 \(\sqrt{\gamma}\) 处脱离 1:

Plotting \(\lambda_1/\lambda_+\) against \(\ell\) puts five different \(\gamma\) values on one axis. Each curve leaves 1 at its own \(\sqrt{\gamma}\):

\[ \sqrt{\gamma} = \sqrt{0.5},\ \sqrt{1},\ \sqrt{2},\ \sqrt{4},\ \sqrt{8} = 0.71, 1.00, 1.41, 2.00, 2.83. \]

这张图是整篇文章最实用的一张:它告诉你,想看见多弱的信号,需要多少样本。\(\gamma = 8\) 时(样本极少)\(\ell\) 要到 2.83 才能被检测到;\(\gamma = 0.5\) 时(样本是特征数的两倍)$ 就够了。

This is the most practical figure in the post: it tells you how many samples you need to see a signal of a given strength. At \(\gamma = 8\) (very few samples) you need \(\ell\) of 2.83; at \(\gamma = 0.5\) (twice as many samples as features) about 0.71 suffices.

不同 \gamma 下 \lambda_1/\lambda_+ 随信号强度的变化,叉号标出各自的检测阈值 \sqrt{\gamma}。 | \lambda_1/\lambda_+ against signal strength for several \gamma; crosses mark the detection thresholds \sqrt{\gamma}.

不同 \(\gamma\) 下 \(\lambda_1/\lambda_+\) 随信号强度的变化,叉号标出各自的检测阈值 \(\sqrt{\gamma}\)。 | \(\lambda_1/\lambda_+\) against signal strength for several \(\gamma\); crosses mark the detection thresholds \(\sqrt{\gamma}\).

11. 三套真实数据 / Three real datasets

理论部分到此结束。接下来的问题是:真实数据落在理论的哪一边?三套数据分别是 bulk RNA-seq、单细胞和 LFQ 蛋白组,它们的 \(\gamma\) 跨越三个数量级,正好可以看三种不同的局面。

Theory ends here. The question now: where does real data sit relative to it? The three datasets are bulk RNA-seq, single cell and LFQ proteomics, their \(\gamma\) spans three orders of magnitude, and they cover three different regimes.

12. airway:8 个样本的地板 / airway: the floor with 8 samples

airway 是 8 个样本的 dexamethasone 处理实验,标准化后有 24,706 个基因,\(\gamma = 3088\)。按公式,\(\lambda_+ = 3200\),除以 \(p\) 就是 13.0% 的噪声地板。

airway is an 8-sample dexamethasone experiment with 24,706 genes after standardisation, so \(\gamma = 3088\). The formula gives \(\lambda_+ = 3200\), and dividing by \(p\) gives a floor of 13.0%.

实测的前七个成分分别解释 26.9%、18.6%、17.9%、12.6%、8.5%、7.9%、7.6%。对照地板 13.0%,前三个成分明显在地板之上,第四个 12.6% 已经开始贴着地板了。

The seven observed components explain 26.9%, 18.6%, 17.9%, 12.6%, 8.5%, 7.9%, 7.6%. Against the floor of 13.0%, the first three sit clearly above it, and the fourth at 12.6% is already hugging it.

airway 的七个成分与噪声地板。柱是实测的方差占比,灰点线是 \lambda_+/p,橙点是置换零模型的 95 分位。 | The seven airway components against the noise floor. Bars are the observed shares, the dotted line is \lambda_+/p, orange dots are the 95th percentile of a permutation null.

airway 的七个成分与噪声地板。柱是实测的方差占比,灰点线是 \(\lambda_+/p\),橙点是置换零模型的 95 分位。 | The seven airway components against the noise floor. Bars are the observed shares, the dotted line is \(\lambda_+/p\), orange dots are the 95th percentile of a permutation null.

13. 平行分析与 PC1 的生物学 / Parallel analysis and what PC1 is

公式给的是渐近边界,有限样本下更好的做法是平行分析:把矩阵的每个数值随机打乱,破坏基因之间、样本之间的关系但保留数值的分布,重复几百次,得到「如果什么都没有,第 \(i\) 个特征值能有多大」的零分布。

The formula gives an asymptotic edge; at finite size a better tool is parallel analysis: shuffle every entry of the matrix, destroying gene-gene and sample-gene relations while keeping the marginal distribution, and repeat a few hundred times to get the null distribution of “how large can the \(i\)-th eigenvalue be if there is nothing there”.

下图把每个序号的零分布画成箱线图,蓝点是观测值。前三个蓝点远在箱子上方,第四个开始落进箱子,与前面「地板在 13.0%」的判断一致。

The figure below draws the null distribution at each index as a boxplot, with observed values as blue dots. The first three dots sit far above their boxes; from the fourth on they fall inside, matching the floor of 13.0% read off earlier.

airway 的平行分析。箱线图是 200 次整体置换得到的零分布,蓝点是观测值。 | Parallel analysis for airway. Boxplots are the null from 200 whole-matrix permutations; blue dots are observed values.

airway 的平行分析。箱线图是 200 次整体置换得到的零分布,蓝点是观测值。 | Parallel analysis for airway. Boxplots are the null from 200 whole-matrix permutations; blue dots are observed values.

那么超过地板的成分是什么?airway 是一个配对的处理实验,第一主成分与 dex 处理状态的相关系数是 0.96,在 PC1–PC2 平面上两类样本完全分开。这是「地板之上确有信号」的一个干净例子:地板告诉你 13.0% 是噪声能给的,而 PC1 给了 26.9%,多出来的部分对应一个真实的处理效应。

So what are the components above the floor? airway is a paired treatment experiment, and PC1 correlates with dex treatment at 0.96; in the PC1–PC2 plane the two groups separate completely. This is a clean case of real signal above the floor: the floor says noise can give 13.0%, PC1 gives 26.9%, and the excess corresponds to a real treatment effect.

airway 的 PC1–PC2,按 dex 处理状态着色。 | PC1–PC2 of airway, coloured by dex treatment.

airway 的 PC1–PC2,按 dex 处理状态着色。 | PC1–PC2 of airway, coloured by dex treatment.

14. PBMC 3k:细胞多、噪声带窄 / PBMC 3k: many cells, a narrow bulk

单细胞的 \(\gamma\) 小得多。用 2,000 个高变基因和 1,200 个细胞,\(\gamma = 1.67\),\(\lambda_+ = 5.25\),地板只有 0.26%。第一主成分解释 4.4%,是地板的 17 倍。

Single-cell \(\gamma\) is much smaller. With 2,000 highly variable genes and 1,200 cells, \(\gamma = 1.67\), \(\lambda_+ = 5.25\), and the floor is only 0.26%. PC1 explains 4.4%, which is 17 times the floor.

但不要因此以为单细胞数据「很干净」。左边的图显示,直到第 14 个成分都还在置换零模型的 95 分位之上;右边的图更值得注意:实测的谱带比 Marchenko–Pastur 曲线更窄也更靠右。这不是公式错了,而是单细胞的数值不满足 MP 的前提(同一行里的方差不相等、大量零值、列之间的测序深度差异),真实数据的谱带比理想噪声更集中。

Do not conclude that single-cell data are “clean”. The left panel shows components up to the 14-th still above the 95th percentile of the permutation null; the right panel is more interesting: the observed bulk is narrower and shifted right relative to the Marchenko–Pastur curve. The formula is not wrong; single-cell values violate its assumptions (unequal variance within a row, many zeros, different sequencing depth across columns), and the real bulk is more concentrated than ideal noise.

PBMC 3k 的谱。左:前 15 个特征值与置换零模型的 95 分位、\lambda_+(点线)。右:全部特征值的直方图与 MP 密度。 | The spectrum of PBMC 3k. Left: the top 15 eigenvalues against the 95th percentile of the permutation null and \lambda_+ (dotted). Right: histogram of all eigenvalues with the MP density.

PBMC 3k 的谱。左:前 15 个特征值与置换零模型的 95 分位、\(\lambda_+\)(点线)。右:全部特征值的直方图与 MP 密度。 | The spectrum of PBMC 3k. Left: the top 15 eigenvalues against the 95th percentile of the permutation null and \(\lambda_+\) (dotted). Right: histogram of all eigenvalues with the MP density.

15. CPTAC:6 次运行的极限 / CPTAC: what six runs can do

蛋白组是另一个极端。CPTAC 的六次 LFQ 运行、1,101 个完整定量的蛋白,\(\gamma = 183.5\),\(\lambda_+ = 211.6\),地板高达 19.2%。

Proteomics is the other extreme. Six LFQ runs of CPTAC with 1,101 completely quantified proteins give \(\gamma = 183.5\), \(\lambda_+ = 211.6\), and a floor as high as 19.2%.

第一主成分解释 32.4%,只有地板的 1.69 倍;平行分析认为只有前 2 个成分是真的。换句话说,在 6 次运行上做 PCA,你能放心解释的成分只有两个,剩下的七个里有五个是噪声的形状。

PC1 explains 32.4%, only 1.69 times the floor, and parallel analysis keeps only the first 2 components. In other words, on six runs you can interpret two components with confidence; the remaining ones are largely the shape of noise.

CPTAC 的五个成分与噪声地板。 | The five CPTAC components against the noise floor.

CPTAC 的五个成分与噪声地板。 | The five CPTAC components against the noise floor.

16. 三套数据放在一起 / The three datasets together

把三套数据的 PC1 与地板画在同一张柱状图上,可以一眼看出 \(\gamma\) 的作用:airway 和 CPTAC 的柱子都是「地板很高、PC1 勉强超过」,PBMC 的柱子则是「地板几乎为零、PC1 远远超过」。同样叫「第一主成分」,在三套数据里的可信度完全不同。

Plotting PC1 and the floor side by side for all three datasets shows the role of \(\gamma\) at a glance: airway and CPTAC are both “high floor, PC1 barely above”, while PBMC is “floor near zero, PC1 far above”. The same phrase, “the first principal component”, carries very different credibility in the three datasets.

三套数据的 PC1 与噪声地板。 | PC1 and the noise floor for the three datasets.

三套数据的 PC1 与噪声地板。 | PC1 and the noise floor for the three datasets.

17. 该保留几个主成分 / How many components to keep

理论给了边界,实践要的是「保留几个」。常见的三条规则是:

Theory gives a boundary; practice asks “how many to keep”. Three common rules are:

  1. Kaiser:保留特征值大于均值的成分(标准化后均值是 1);
    Kaiser: keep components whose eigenvalue exceeds the mean, which is 1 after standardisation.
  2. 肘部:保留碎石图上「下降最快」的那个位置之前的成分;
    Elbow: keep components before the steepest drop in the scree plot.
  3. 零模型边界:保留大于置换零模型(或 \(\lambda_+\))的成分。
    Null edge: keep components above the permutation null, or above \(\lambda_+\).

在模拟里,\(p = 200\)、\(n = 500\)、真实信号数从 0 到 5,各跑 40 次,看三条规则平均估出几个:

In simulation with \(p = 200\), \(n = 500\) and a true signal count from 0 to 5, 40 runs each, here is the average estimate of the three rules:

真实 k / True k 零模型边界 / Null edge Kaiser 肘部 / Elbow
0 0.07 86.1 3.30
1 1.05 69.5 1.00
2 2.05 57.8 2.00
3 3.00 49.5 3.00
5 5.00 41.1 5.00

结论很清楚:Kaiser 在 \(p \gg n\) 时完全失效,因为它把谱带里所有大于 1 的噪声都当成信号,估出来的是几十个;肘部在有信号时还不错,但在纯噪声上会硬找出几个成分;零模型边界最稳,唯一的偏差是偶尔多算一个(\(k = 1\) 时估成 1.05)。

The conclusion is clear: Kaiser fails completely when \(p \gg n\), because it counts every noise eigenvalue in the bulk above 1 and lands in the dozens; the elbow does well when there is signal but invents components on pure noise; the null edge is the most stable, with the only deviation being an occasional extra component (at \(k = 1\) it estimates 1.05).

三条规则的平均估计值。灰虚线是 y = x。 | Mean estimate of the three rules. The dashed line is y = x.

三条规则的平均估计值。灰虚线是 \(y = x\)。 | Mean estimate of the three rules. The dashed line is \(y = x\).

18. 硬阈值与最优降噪 / Hard thresholding and optimal denoising

知道哪些成分是噪声之后,一个自然的想法是把它们直接扔掉:对奇异值做硬阈值,只保留大于 \(\tau\) 的那些。Gavish 与 Donoho 给出了 \(m \times n\) 矩阵的最优阈值

Once you know which components are noise, a natural move is to throw them away: hard-threshold the singular values and keep those above \(\tau\). Gavish and Donoho give the optimal threshold for an \(m \times n\) matrix as

\[ \tau = \omega(\beta)\,\sqrt{N}\,\sigma, \qquad \omega(\beta) = 0.56\beta^3 - 0.95\beta^2 + 1.82\beta + 1.43, \]

其中 \(\beta = m/N\)、\(N = \max(m,n)\)。

with \(\beta = m/N\) and \(N = \max(m,n)\).

在 \(200 \times 500\)、三个已知信号的模拟里,\(\tau_{GD} = 45.66\)。把阈值从 0 扫到 \(1.6\,\tau_{GD}\),硬阈值的均方误差在 0.81 倍 \(\tau_{GD}\) 附近到 \(\tau_{GD}\) 之间完全平坦(因为这一段里被保留的奇异值集合没有变),随后开始上升。不降噪时(\(\tau = 0\))误差是 1.000,阈值取在 \(\tau_{GD}\) 时是 0.0237:相差四十倍。

In the simulation with \(200 \times 500\) and three known signals, \(\tau_{GD} = 45.66\). Sweeping the threshold from 0 to \(1.6\,\tau_{GD}\), the hard-threshold mean squared error is completely flat between 0.81 and 1 times \(\tau_{GD}\) (the set of kept singular values does not change over that range) and rises afterwards. Without denoising (\(\tau = 0\)) the error is 1.000; at \(\tau_{GD}\) it is 0.0237, a forty-fold difference.

软阈值(把每个奇异值减去 \(\tau\))在小阈值处误差更低,但在最优区附近不如硬阈值。这是一个反复出现的取舍:软阈值偏差大、方差小,硬阈值反之。

Soft thresholding (subtracting \(\tau\) from every singular value) has lower error at small thresholds but loses to hard thresholding near the optimum. It is the usual bias-variance trade-off: soft has more bias and less variance, hard the reverse.

硬阈值与软阈值的均方误差随阈值变化。灰虚线是 \tau_{GD},橙点线是实测最优。 | Mean squared error of hard and soft thresholding against the threshold. The dashed line is \tau_{GD}, the dotted line is the empirical optimum.

硬阈值与软阈值的均方误差随阈值变化。灰虚线是 \(\tau_{GD}\),橙点线是实测最优。 | Mean squared error of hard and soft thresholding against the threshold. The dashed line is \(\tau_{GD}\), the dotted line is the empirical optimum.

19. 收缩估计 / Shrinkage

另一种降噪方式不是扔成分,而是把整个协方差矩阵往一个简单目标拉:

Another way to denoise is not to discard components but to pull the whole covariance towards a simple target:

\[ \hat\Sigma = (1-\delta) S + \delta\, \mu I, \qquad \mu = \frac{\operatorname{tr} S}{p}. \]

Ledoit 与 Wolf 给出了使期望 Frobenius 风险最小的 \(\delta\) 的解析解。在 \(p = 100\)、\(n = 60\)、真实协方差是「三个信号加上单位阵」的模拟里,解析解给出 \(\delta = 0.92\),与网格搜索的最优值 0.94 几乎一致;风险从 186.1 降到 12.84。

Ledoit and Wolf give an analytic \(\delta\) that minimises the expected Frobenius risk. In a simulation with \(p = 100\), \(n = 60\) and a true covariance of “three signals plus identity”, the analytic solution gives \(\delta = 0.92\), essentially the grid-search optimum of 0.94; the risk falls from 186.1 to 12.84.

但右边的图给出了一个警告:Frobenius 最优的收缩会把三个信号特征值一起拉向 \(\mu\),从 4、3、2 拉到一个很窄的区间。如果你的目的正是解释前几个方向,这个「最优」是有害的。降噪准则和下游目的是两件事。

But the right panel is a warning: Frobenius-optimal shrinkage drags the three signal eigenvalues towards \(\mu\), from 4, 3, 2 into a narrow band. If your goal is precisely to interpret the leading directions, that “optimum” is harmful. The denoising criterion and the downstream goal are two different things.

左:Frobenius 风险随收缩强度 \delta 的变化,红虚线是解析解,绿点线是网格最优。右:样本、收缩后与真实协方差的特征值分布。 | Left: Frobenius risk against shrinkage \delta; the dashed line is the analytic solution, the dotted line the grid optimum. Right: eigenvalue distributions of the sample, shrunk and true covariances.

左:Frobenius 风险随收缩强度 \(\delta\) 的变化,红虚线是解析解,绿点线是网格最优。右:样本、收缩后与真实协方差的特征值分布。 | Left: Frobenius risk against shrinkage \(\delta\); the dashed line is the analytic solution, the dotted line the grid optimum. Right: eigenvalue distributions of the sample, shrunk and true covariances.

20. 样本数决定地板 / Sample size sets the floor

最后回到 airway,做一个反事实:如果只有 \(n\) 个样本,地板会是多少?\(\gamma = p/n\) 随 \(n\) 变化,\(\lambda_+/p\) 也随之变化:

Finally, a counterfactual on airway: with only \(n\) samples, what would the floor be? \(\gamma = p/n\) varies with \(n\), and so does \(\lambda_+/p\):

样本数 n / Samples 2 3 4 5 6 7 8
地板 / Floor 50.9% 34.1% 25.6% 20.6% 17.2% 14.8% 13.0%

实测的 PC1 是 26.9%。也就是说,这套数据至少需要 4 个样本,第一主成分才可能超过噪声地板;用 3 个样本做同样的分析,第一主成分连噪声都算不上。

The observed PC1 is 26.9%. So this dataset needs at least 4 samples before PC1 can exceed the floor; with three samples, the same analysis would find PC1 indistinguishable from noise.

airway 的噪声地板随样本数的变化,蓝虚线是实测的 PC1 占比。 | The airway noise floor as a function of sample size; the blue dashed line is the observed PC1 share.

airway 的噪声地板随样本数的变化,蓝虚线是实测的 PC1 占比。 | The airway noise floor as a function of sample size; the blue dashed line is the observed PC1 share.

21. 一张检查清单 / A checklist

把上面的内容压缩成五条,下次做 PCA 之前可以照着走一遍:

Compressed into five steps to run before your next PCA:

  1. 先算 \(\gamma = p/n\) 和 \(\lambda_+ = (1+\sqrt{\gamma})^2\),再算地板 \(\lambda_+/p\);
    Compute \(\gamma = p/n\) and \(\lambda_+ = (1+\sqrt{\gamma})^2\), then the floor \(\lambda_+/p\).
  2. 把「第一主成分解释了多少方差」和地板比,不要和 100% 比;
    Compare “the share of variance in PC1” with the floor, not with 100%.
  3. 用置换零模型做平行分析,不要用 Kaiser;肘部只作为参考;
    Use a permutation null for parallel analysis rather than Kaiser; treat the elbow as a hint.
  4. 记住 \(n\) 个样本最多给出 \(n-1\) 个成分,且边缘有 \(\sim n^{-2/3}\) 的涨落;
    Remember that \(n\) samples give at most \(n-1\) components, and that the edge fluctuates like \(n^{-2/3}\).
  5. 降噪前先想清楚目的:Frobenius 最优的收缩会压掉你要解释的那几个方向。
    Decide the goal before denoising: Frobenius-optimal shrinkage flattens exactly the directions you want to interpret.

22. 局限与没做的事 / Limitations

这篇文章没做的事也很清楚。第一,Marchenko–Pastur 假设矩阵元素独立同分布,真实的组学数据从来不是这样(基因之间有调控关系、样本之间有批次),所以它是零模型,不是数据生成模型;本文用置换零模型来补这一点,但置换本身假设「可交换」,对时间序列或配对设计不成立。第二,BBP 定理讨论的是单个 spike 的极限,多个 spike 之间会互相干扰,本文没有量化这种干扰的有限样本代价。第三,硬阈值与收缩都只在高斯噪声下保证最优,单细胞的计数噪声既不独立也不同方差,实际效果会打折扣。

What this post does not do is equally clear. First, Marchenko–Pastur assumes iid entries, which omics data never satisfy (genes are regulated, samples have batches), so it is a null model, not a generative model; the permutation null patches this, but permutation assumes exchangeability, which fails for time series or paired designs. Second, BBP is a single-spike limit, and multiple spikes interfere with each other; the finite-sample cost of that interference is not quantified here. Third, hard thresholding and shrinkage are optimal under Gaussian noise, while single-cell counts are neither independent nor homoscedastic, so their real-world performance is weaker.

参考文献 / References

  1. Marchenko, V. A., & Pastur, L. A. (1967). Distribution of eigenvalues for some sets of random matrices. Mathematics of the USSR-Sbornik 1, 457–483. doi:10.1070/SM1967v001n04ABEH001994
  2. Baik, J., Ben Arous, G., & Péché, S. (2005). Phase transition of the largest eigenvalue for nonnull complex sample covariance matrices. The Annals of Probability 33, 1643–1697. doi:10.1214/009117905000000233
  3. Johnstone, I. M. (2001). On the distribution of the largest eigenvalue in principal components analysis. The Annals of Statistics 29, 295–327. doi:10.1214/aos/1009210544
  4. Tracy, C. A., & Widom, H. (1994). Level-spacing distributions and the Airy kernel. Communications in Mathematical Physics 159, 151–174. doi:10.1007/BF02100489
  5. Gavish, M., & Donoho, D. L. (2014). The optimal hard threshold for singular values is 4/√3. IEEE Transactions on Information Theory 60, 5040–5053. doi:10.1109/TIT.2014.2323359
  6. Ledoit, O., & Wolf, M. (2004). A well-conditioned estimator for large-dimensional covariance matrices. Journal of Multivariate Analysis 88, 365–411. doi:10.1016/S0047-259X(03)00096-4
  7. Horn, J. L. (1965). A rationale and test for the number of factors in factor analysis. Psychometrika 30, 179–185. doi:10.1007/BF02289447
  8. airway 数据:airway Bioconductor 包(Himes et al., 2014, PLOS ONE 9, e99625)。PBMC 3k:10x Genomics,https://cf.10xgenomics.com/samples/cell-exp/1.1.0/pbmc3k/。CPTAC 子集:msqrob2data,https://github.com/statOmics/msqrob2data。

前七条有 DOI;第八条是数据来源,给的是包名与仓库链接。